package apps.softtech.fastmarket.model;

import com.google.android.gms.games.internal.constants.AvailabilityCode;

import android.content.ContentValues;
import android.database.Cursor;
import android.graphics.drawable.Drawable;

public class Product {

	

	public static final String TABLE_NAME = "Product";

	public static final String PRODUCT_ID = "st_ProductId";
	private int productId;

	public static final String USERID = "st_UserId";
	private int userId;

	public static final String CREATED_DATE = "st_CreatedDate";
	private String createdDate;

	public static final String CATEGORY_ID = "st_CategoryId";
	private int categoryId;

	public static final String LAST_UPDATE = "st_LastUpdate";
	private String lastUpdate;

	public static final String OFFER_ID = "st_OfferId";
	private int offerId;

	public static final String DESCRIPTION = "st_Description";
	private String description;

	public static final String PRODUCT_NAME = "st_ProductName";
	private String productName;
	
	public static final String AVATAR_PATH = "st_AvatarPath";
	private String AvatarPath;

	public static final String IMAGE1 = "st_Image1";
	private Drawable image1;

	public static final String IMAGE2 = "st_Image2";
	private Drawable image2;

	public static final String IMAGE3 = "st_Image3";
	private Drawable image3;

	public static final String PRICE = "st_Price";
	private float price;

	public Product() {
		super();
	}

	public Product(int productId,String productName, int userId, String createdDate,
			int categoryId, String lastUpdate, int offerId,
			String description, String AvatarPath) {
		super();
		this.productId = productId;
		this.productName = productName;
		this.userId = userId;
		this.createdDate = createdDate;
		this.categoryId = categoryId;
		this.lastUpdate = lastUpdate;
		this.offerId = offerId;
		this.description = description;
		this.AvatarPath = AvatarPath;
	}
//
//	public Product(int userId, String createdDate, int categoryId,
//			String lastUpdate, int offerId, String description) {
//		super();
//		this.userId = userId;
//		this.createdDate = createdDate;
//		this.categoryId = categoryId;
//		this.lastUpdate = lastUpdate;
//		this.offerId = offerId;
//		this.description = description;
//	}
	
	public Product(int productId, int userId, String createdDate,
			int categoryId, String lastUpdate, int offerId,
			String description, String AvatarPath) {
		super();
		this.productId = productId;
		this.userId = userId;
		this.createdDate = createdDate;
		this.categoryId = categoryId;
		this.lastUpdate = lastUpdate;
		this.offerId = offerId;
		this.description = description;
		this.AvatarPath = AvatarPath;
	}

	/**
	 * get value of Product
	 * 
	 * @return ContenValue
	 */
	public ContentValues getValueProduct() {
		ContentValues values = new ContentValues();
		values.put(Product.PRODUCT_ID, this.getProductId());
		values.put(USERID, this.getUserId());
		values.put(CREATED_DATE, this.getCreatedDate());
		values.put(CATEGORY_ID, this.getCategoryId());
		values.put(LAST_UPDATE, this.getLastUpdate());
		values.put(OFFER_ID, this.getOfferId());
		values.put(DESCRIPTION, this.getDescription());
		values.put(AVATAR_PATH, this.getAvatarPath());
		values.put(PRODUCT_NAME, this.getProductName());

		return values;
	}

	public void setValueFromCursor(Cursor c) {
		Product product = new Product();

		if (c.getColumnIndex(PRODUCT_ID) >= 0) {
			setProductId(c.getInt(c.getColumnIndex(PRODUCT_ID)));
		}
		if (c.getColumnIndex(CREATED_DATE) >= 0) {
			setCreatedDate(c.getString(c.getColumnIndex(CREATED_DATE)));
		}
		if (c.getColumnIndex(PRODUCT_ID) >= 0) {
			setProductId(c.getInt(c.getColumnIndex(PRODUCT_ID)));
		}
		if (c.getColumnIndex(DESCRIPTION) >= 0) {
			setDescription(c.getString(c.getColumnIndex(DESCRIPTION)));
		}
		
		if (c.getColumnIndex(AVATAR_PATH) >= 0) {
			setAvatarPath(c.getString(c.getColumnIndex(AVATAR_PATH)));
		}
		
		if (c.getColumnIndex(PRODUCT_NAME) >= 0) {
			setProductName(c.getString(c.getColumnIndex(PRODUCT_NAME)));
		}
		
		if (c.getColumnIndex(USERID) >= 0) {
			setUserId(c.getInt(c.getColumnIndex(USERID)));
		}
		if (c.getColumnIndex(OFFER_ID) >= 0) {
			setOfferId(c.getInt(c.getColumnIndex(OFFER_ID)));
		}
		if (c.getColumnIndex(LAST_UPDATE) >= 0) {
			setLastUpdate(c.getString(c.getColumnIndex(LAST_UPDATE)));
		}


	}



	public int getProductId() {
		return productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(String createdDate) {
		this.createdDate = createdDate;
	}

	public int getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(int categoryId) {
		this.categoryId = categoryId;
	}

	public String getLastUpdate() {
		return lastUpdate;
	}

	public void setLastUpdate(String lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	public int getOfferId() {
		return offerId;
	}

	public void setOfferId(int offerId) {
		this.offerId = offerId;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getAvatarPath() {
		return AvatarPath;
	}

	public void setAvatarPath(String avatarPath) {
		AvatarPath = avatarPath;
	}

	public Drawable getImage1() {
		return image1;
	}

	public void setImage1(Drawable image1) {
		this.image1 = image1;
	}

	public Drawable getImage2() {
		return image2;
	}

	public void setImage2(Drawable image2) {
		this.image2 = image2;
	}

	public Drawable getImage3() {
		return image3;
	}

	public void setImage3(Drawable image3) {
		this.image3 = image3;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	
	public String getProductName() {
		return productName;
	}

	

	public void setProductName(String productName) {
		this.productName = productName;
	}

}
